<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ include file="/JSP/Common/head.jsp"%>
<div class="nowPosition">你所在的位置是修改订单</div>
<div class="updateOrd-div">
    <p style="padding-left: 8%;font-family: '楷体';color: red">${MESSAGE}</p>
    <form action="${pageContext.request.contextPath}/JSP/ord.go" method="post" id="updateOrdForm">
        <input type="hidden" name="method" value="updateOrdSubmit">
        <input type="hidden" name="ordId" value="${ord.id }"/>
        <label>
            <span class="updateOrd-span">编号</span>
            <input id="ordCode" name="ordCode" type="text" disabled="disabled" value="${ord.ordCode}" class="updateOrd-input-text inshadow txtclick" />
        </label><br />
        <label>
            <span class="updateOrd-span">名称</span>
            <input id="ordName" name="ordName" type="text" value="${ord.ordName}" class="updateOrd-input-text inshadow txtclick" placeholder="请输入公司名" />
            <span style="color: red;font-family: '楷体';"></span>
        </label><br />
        <label>
            <span class="updateOrd-span">数量</span>
            <input id="count" name="count" type="text" value="${ord.count}" class="updateOrd-input-text inshadow txtclick" placeholder="请输入姓名" />
            <span style="color: red;font-family: '楷体';"></span>
        </label><br />
        <label>
            <span class="updateOrd-span">数量单位</span>
            <input id="unit" name="unit" type="text" value="${ord.unit}" class="updateOrd-input-text inshadow txtclick" placeholder="请输入出生日期" />
            <span style="color: red;font-family: '楷体';"></span>
        </label><br />
        <label>
            <span class="updateOrd-span">金额</span>
            <input id="totalPrice" name="totalPrice" type="text" value="${ord.totalPrice}" class="updateOrd-input-text inshadow txtclick" placeholder="请输入用户住址" />
            <span  style="color: red;font-family: '楷体';"></span>
        </label><br />
        <label>
            <span class="updateOrd-span">是否支付</span>
            <select id="isPay" name="isPay" class="updateSup-genderSelect inshadow txtclick">
                <option <c:if test='${ord.isPay == "已支付"}'>selected="selected"</c:if> value="已支付">已支付</option>
                <option <c:if test='${ord.isPay == "未支付"}'>selected="selected"</c:if> value="未支付">未支付</option>
            </select>
        </label><br />
        <label>
            <span class="updateOrd-span">商品描述</span>
            <input id="describe" name="describe" type="text" value="${ord.describe}" class="updateOrd-input-text inshadow txtclick" placeholder="请输入电话号码" />
        </label><br />
        <label>
            <span class="updateOrd-span">供应商</span>
            <input id="supName" name="supName" type="text" disabled="disabled" value="${ord.supName}" class="updateOrd-input-text inshadow txtclick" />
        </label><br />
        <label>
            <input id="updateOrd" type="button" class="btnclick addUser-input-save inshadow-white" value="修改" />
        </label>
        <label>
            <input type="button" class="goback btnclick addUser-input-goback inshadow-white" value="返回" />
        </label>
    </form>
</div>
<%@ include file="/JSP/Common/foot.jsp"%>
<%--<script type="text/javascript" src="${pageContext.request.contextPath}/JS/orderUpdate.js" ></script>--%>
<script type="text/javascript">
    $(function () {
        var ordName = $("#ordName");
        var count = $("#count");
        var unit = $("#unit");
        var totalPrice = $("#totalPrice");
        var describe = $("#describe");
        var updateOrd = $("#updateOrd");
        var updateOrdForm = $("#updateOrdForm");


        ordName.attr("validateStatus", true);
        count.attr("validateStatus", true);
        unit.attr("validateStatus", true);
        totalPrice.attr("validateStatus", true);
        describe.attr("validateStatus", true);

        ordName.on({
            focus:function () {
                setStyles(ordName.next(), {'color':'red'}, "(请输入名称)", false);
            },
            blur:function () {
                var len = ordName.val().length;
                if (len > 0){
                    setStyles(ordName.next(), {'color':'#87CEED'}, getImgTick() + "(Ok)", true);
                }else {
                    setStyles(ordName.next(), {'color':'red'}, getImgCross() + "(不能为空)", false);
                }
            }
        });

        count.on({
            focus:function () {
                setStyles(count.next(), {'color':'red'}, "(请输入数量)", false);
            },
            blur:function () {
                var len = count.val().length;
                if (len > 0){
                    setStyles(count.next(), {'color':'#87CEED'}, getImgTick() + "(Ok)", true);
                }else {
                    setStyles(count.next(), {'color':'red'}, getImgCross() + "(不能为空)", false);
                }
            }
        });

        unit.on({
            focus:function () {
                setStyles(unit.next(), {'color':'red'}, "(请输入单位)", false);
            },
            blur:function () {
                var len = unit.val().length;
                if (len > 0){
                    setStyles(unit.next(), {'color':'#87CEED'}, getImgTick() + "(Ok)", true);
                }else {
                    setStyles(unit.next(), {'color':'red'}, getImgCross() + "(不能为空)", false);
                }
            }
        });

        totalPrice.on({
            focus:function () {
                setStyles(totalPrice.next(), {'color':'red'}, "(请输入金额)", false);
            },
            blur:function () {
                var len = totalPrice.val().length;
                if (len > 0){
                    setStyles(totalPrice.next(), {'color':'#87CEED'}, getImgTick() + "(Ok)", true);
                }else {
                    setStyles(totalPrice.next(), {'color':'red'}, getImgCross() + "(不能为空)", false);
                }
            }
        });

        describe.on({
            blur:function () {
                var len = describe.val().length;
                if (len > 0){
                    setStyles(describe.next(), {'color':'#87CEED'}, getImgTick() + "(Ok)", true);
                }else {
                    setStyles(describe.next(), {'color':'red'}, getImgCross() + "(不能为空)", false);
                }
            }
        });


        updateOrd.on({
            click:function (){
                console.log(ordName.attr("validateStatus"));
                console.log(count.attr("validateStatus"));
                console.log(unit.attr("validateStatus"));
                console.log(totalPrice.attr("validateStatus"));
                console.log(describe.attr("validateStatus"));
                if(ordName.attr("validateStatus") != "true"){
                    ordName.blur();
                }else if(count.attr("validateStatus") != "true"){
                    count.blur();
                }else if(unit.attr("validateStatus") != "true"){
                    unit.blur();
                }else if(totalPrice.attr("validateStatus") != "true"){
                    totalPrice.blur();
                }else if(describe.attr("validateStatus") != "true"){
                    describe.blur();
                }else{
                    if(confirm("是否确认提交数据")){
                        updateOrdForm.submit();
                    }
                }
            }
        });

    })
</script>